<template>
  <div>
      <!-- 输入框 -->
      <header class="header">
      <h1>小黑记事本</h1>
      <input v-model="inputValue" placeholder="请输入任务" class="new-todo" @keydown="AddItem"/>
      <button class="add" @click="AddItem">添加任务</button>
    </header>

  </div>
</template>

<script>
import EventBus from '../Utility/EventBus';  
export default {
  inject:['color','userInfo'],
  created() {
    console.log(this.color);
    console.log(this.userInfo);
  },
  data() {
    return {
      inputValue: ""
    }
  },
  methods: {
    AddItem() {
      console.log("添加任务");
      if (this.inputValue.trim() !== "") {
        this.$emit("add-item", this.inputValue);
        this.inputValue = "";
      }
      //派送事件
      EventBus.$emit("updateAllCount", 
        this.inputValue
      );
    }
  }

}
</script>

<style>

</style>